/*
 * @Author: Njpyy
 * @Date: 2024-03-14 09:01:15
 * @LastEditors: Njpyy
 * @LastEditTime: 2024-03-17 21:56:59
 * @FilePath: /big-event/src/api/user.js
 * @Description: 
 */
//导入request.js请求工具
import request from '@/utils/request'

//注册接口的函数-(x-www-form-urlencoded)
export const userRegisterService = (registerData) => {
    const params = new URLSearchParams()
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    return request.post("/user/register", params)
}

//登录接口的函数-(x-www-form-urlencoded)
export const userLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key])
    }
    return request.post("/user/login", params)
}

//获取用户信息-(application/json)
export const userInfoService = () => {
    return request.get("/user/userInfo")
}

//更新用户信息-(application/json)
export const userInfoUpdateService = (userInfoData) => {
    return request.put("/user/update", userInfoData)
}

//更新用户头像-(queryString)
export const userAvatarUpdateService = (imgUrl) => {
    //queryString也可以用如下方式传参
    const params = new URLSearchParams()
    params.append('avatarUrl', imgUrl)
    return request.patch('/user/updateAvatar', params)
}